The Default Library · Mathematics 15 of 20 · 3 min read

Markov Chains: Random Walks, PageRank, and Predicting the Next Step

A Markov Chain is a system that transitions between states based on fixed probabilities—memoryless of the past, yet predicting the future.

In 1906, Russian mathematician Andrey Markov introduced a revolutionary concept in probability theory: a system that moves from one state to another where the probability of the next step depends only on the current state, regardless of the history of how the system arrived there. This property—known as memorylessness or the Markov Property—became the foundation for predicting weather patterns, financial stock fluctuations, board game odds, search engine algorithms, and AI language models.

3-State Weather Markov Simulator
Tomorrow's weather here depends only on today's, through the fixed odds on the arrows. Today sunny? 60% chance tomorrow is sunny again, 30% cloudy, 10% rainy. Pick a starting day, then let the walker wander and watch the share of days in each state.
30%10%30%30%20%40%60%40%40%SunnyCloudyRainy
Chance of tomorrow's weather, given today's
Today☀️ Sunny⛅ Cloudy🌧️ Rainy
☀️ Sunny60%30%10%
⛅ Cloudy30%40%30%
🌧️ Rainy20%40%40%

Run this chain for long enough and it spends about 39% of days sunny, 36% cloudy and 25% rainy (exactly 24/61, 22/61 and 15/61) — whatever the weather on day one.

Day 1: ☀️ Sunny

The thin marks show the long-run shares: 39.3%, 36.1% and 24.6%.

How Google PageRank Uses Markov Chains

In 1998, Stanford graduate students Larry Page and Sergey Brin revolutionized internet search by inventing PageRank. They modeled the entire World Wide Web as a giant Markov Chain:

By calculating the long-term steady-state probability of where this random surfer spends their time, Google ranked web pages by importance! Pages with many high-quality incoming links had a higher steady-state probability, placing them at the top of search results.

Markov Chains in Language and AI

Before modern deep neural networks, early auto-complete and speech recognition engines used Markov Text Generators (n-gram models). By analyzing a large text corpus, the model calculates the probability of the next word given the current word: e.g., after the word "peanut", the word "butter" might have, say, a 70% transition probability in a given body of text.

Try it: forecast further and further ahead
No coin flips this time: multiplying the table by itself gives the exact odds for any number of days ahead. The further out you look, the less today matters — every starting point drifts to the same 39 / 36 / 25 split.
If today is 🌧️, then…☀️⛅🌧️
1 day later20%40%40%
2 days later32%38%30%
3 days later37%37%27%
5 days later39%36%25%
10 days later39%36%25%
Takeaways

A Markov Chain is a memoryless stochastic process where the next state depends solely on the current state. Regardless of starting conditions, any ergodic Markov chain — one that can reach every state and doesn't cycle in lockstep — converges over time toward a stable steady-state equilibrium distribution. This mathematical property powers search engines (PageRank), predictive auto-complete, financial risk modeling, and weather forecasting.

Action step: Pick a different starting day above and tap "Run 1,000 days" a few times. Notice how the share of sunny, cloudy and rainy days always settles near the same 39 / 36 / 25 split.

Sources: Sheldon Ross's Introduction to Probability Models. Larry Page & Sergey Brin's 1998 PageRank paper. Charles Grinstead's Introduction to Probability.

Go Deeper:
📘 Introduction to Probability Models — Sheldon M. Ross (the classic textbook on stochastic processes)
🌐 Setosa.io — Visual Explanation of Markov Chains